package com.dept;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Author Str
 * @Date 2022/1/6 15:58
 * @Description :
 */
@SpringBootApplication
@EnableEurekaClient
// @EnableDiscoveryClient是使用DiscoveryClient的前提
@EnableDiscoveryClient
public class DeptConsumerApplication {

    // @LoadBalanced为负载均衡注解，不用这个注解服务消费者拿不到提供者的服务，会报无法解析服务名称错误
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(DeptConsumerApplication.class, args);
    }
}
